<?php
$dateToday=date("Y-m-d");
$filename=$_GET['filename'];
$orgFile = fopen($filename,"r");
$counter=0;
$bigarray= array();
while(($lineData = fgetcsv($orgFile,0))!= FALSE){
	if($counter>0 and $lineData[12]!=""){
		if(in_array($lineData[12],$bigarray)!==false){
			$theKey = array_search($lineData[12],$bigarray);
			$tempval = $bigarray[$theKey + 2];
			$bigarray[$theKey + 2] = $tempval + $lineData[15];
			
			}
		else{
			array_push($bigarray,$lineData[12]);
			array_push($bigarray,$lineData[14]);
			array_push($bigarray,$lineData[15]);
			array_push($bigarray,$lineData[31]);			
			}	
	}
	$counter++;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $dateToday; ?> Pick Up in the warehouse </title>
</head>

<body style="margin:0;">
<H1>STOCK PICKUP  SLIPS on <?php echo $dateToday;?>  Sign By :______<H1>
<table width="750" border="1" cellspacing="0" cellpadding="0" style="font-family:Arial; font-size:12px;">
  <tr>
    <td style="width:100px;">#item ID</td>
    <td style="width:70px;">Thumb</td>
    <td style="width:300px;">Title</td>
    <td style="width:30px;">Qty</td>
    <td style="width:100px;">Customer Label</td>
    <td style="width:50px;">&nbsp;</td>
    <td style="width:50px;">&nbsp;</td>
    <td style="width:50px;">Tick</td>
  </tr>
<?php
foreach($bigarray as $key => $value){
if($key%4==0){
?>  
  
  <tr>
    <td><?php 
	
	echo $value;
	
	?></td>
    <td><img src="http://thumbs.ebaystatic.com/pict/<?php echo $value;?>6464_.jpg" border="0" /></td>
    <td>
    <?php
	echo $bigarray[$key+1];
	?>    
    </td>
    <td><?php

	echo $bigarray[$key+2];
	?> 	
	</td>
    <td valign="top">
	<?php
	echo $bigarray[$key+3];
	?>
    </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>[ ____]</td>
  </tr>
<?php
}
}
?>
</table>
</body>
</html>